﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace LastfmNet.Models
{
    public class Tag : LastfmModelBase, ITag
    {
        public Tag()
        {
            this.Name = string.Empty;
            this.Url = string.Empty;
            this.Reach = 0;
            this.Taggings = 0;
            this.Streamable = false;
            this.Wiki = new Wiki();
        }

        public Tag(XmlNode tagNode)
        : this()
        {
            if (tagNode == null) return;
            this.InitializeFromXmlNode(tagNode);
        }

        public override void InitializeFromXmlNode(XmlNode node)
        {
            if (node == null) return;
            this.Name = node.GetChildValue("name");
            this.Url = node.GetChildValue("url");
            this.Reach = node.GetChildValue("reach").ToInteger();
            this.Taggings = node.GetChildValue("taggings").ToInteger();
            this.Streamable = node.GetChildValue("streamable").ToBoolean();
            this.Wiki = new Wiki(node.GetChild("wiki"));
        }

        public string Name { get; set; }

        public string Url { get; set; }

        public int Reach { get; set; }

        public int Taggings { get; set; }

        public bool Streamable { get; set; }

        public Wiki Wiki { get; set; }
    }
}
